<template>
	<view>
		<view v-show="isshow" class="leads">
			<lead v-if="isshow" :parentHandler="parentHandler" ></lead>
		</view>
		<view v-show="!isshow" id="loginback">
			<input type="text" id="username" v-model="logindata.username" placeholder="用户名">
			<input type="password"  id="password" v-model="logindata.password" placeholder="密码">
			<button @click="postdata()">确认登录</button>
		</view>
	</view>
</template>

<script>
	import lead from "../../loginBefore/login/lead.vue"
	export default {
		components:{lead},
		data() {
			return {
				isshow:false,
				logindata:{
					username:'zhangsan',
					password:'123456',
				}
			}
		},
		beforeMount() {
			
		},
		methods: {
			 parentHandler() {
			      this.isshow = false
			},
			postdata(){
				uni.request({
					method:'POST',
				    url: 'http://42.192.15.126:3000/pan/login', //仅为示例，并非真实接口地址。
				    data: this.logindata,
				    success: (res) => {
				        console.log(res.data.token);
				        uni.setStorage({
				        	key: 'token',
				        	data: res.data.token,
				        	success: function () {
				        		uni.reLaunch({
				        			url: '../../../pages/index/index'
				        		});
				        	}
				        });
				    }
				});
			}
		}
	}
</script>

<style scoped>
	uni-view,uni-page-body{
		width: 100%;
		height: 100%;
	}
#loginback{
	width: 100%;
	height: 100%;
	background-image: url('https://img.axureshop.com/25/b4/10/25b4104f10ee4caebb973eb8225c8a01/images/%E7%99%BB%E5%BD%95/u62.jpg');
	background-repeat: no-repeat;
}
</style>
